﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;

public partial class AdminCMS_tab_Message_List : System.Web.UI.Page
{
    #region 参数
    [RequestQuery.Query(QueryKey = "isnewmsg")]
    public bool IsNewMsg = true;    //新消息
    [RequestQuery.Query(QueryKey = "keyword")]
    public string keyword = string.Empty;  //关键词
    #endregion

    protected void Page_Load(object sender, EventArgs e)
    {
        RequestQuery.SetQueryValues();

        if (!IsPostBack)
        {
            ddl_IsNewMsg.SelectedValue = Convert.ToInt32(IsNewMsg).ToString();
            txt_keyword.Text = keyword;

            ProSplitPage1.DataSource = GetPagingData();  //给分页控件附值
            ProSplitPage1.AppendQuery = RequestQuery.GetQueryValues();
            repeater1.DataSource = ProSplitPage1.SplitSource(); //返回拆分结果
            repeater1.DataBind();
        }
    }

    #region 分页方法

    public DataSet GetPagingData()
    {
        StringBuilder sql = new StringBuilder();
        sql.Append(
@"SELECT msg_Title, msg_PubDate, msg_MsgName, msg_ID, msg_Content
FROM [tab_Message] where msg_IsNewMsg = ").Append(IsNewMsg);
        /* 追加条件*/
        //新消息
        if (keyword != string.Empty)
        {
            sql.Append(" AND msg_Title like '%").Append(keyword).Append("%'");
        }

        string Primary = "msg_ID"; //主键
        string Orderby = Primary + " DESC";  //排序
        return DataEntity.Common.ExecuteSplitPage(sql.ToString(), Primary, Orderby, ProSplitPage1.MaxRows, ProSplitPage1.PageIndex);
    }
    #endregion
}
